From 4a1d114fa3a5d6bef1f71222787c1f6c3a952284 Mon Sep 17 00:00:00 2001
From: Nicolas Serafini <nicolas.serafini@sensefly.com>
Date: Thu, 24 Jan 2019 10:11:42 +0100
Subject: [PATCH] mbim: add optional copy of TEMP_FAILURE_RETRY macro (fix musl
 compile)

TEMP_FAILURE_RETRY is not available on musl.

Signed-off-by: Nicolas Serafini <nicolas.serafini@sensefly.com>
---
 drivers/mbimmodem/mbim.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mbimmodem/mbim.c b/drivers/mbimmodem/mbim.c
index 54b18acf..4b040528 100644
--- a/drivers/mbimmodem/mbim.c
+++ b/drivers/mbimmodem/mbim.c
@@ -37,6 +37,16 @@
 #include "mbim-message.h"
 #include "mbim-private.h"
 
+/* taken from glibc unistd.h for musl support */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression)             \
+  (__extension__                                   \
+    ({ long int __result;                          \
+       do __result = (long int) (expression);      \
+       while (__result == -1L && errno == EINTR);  \
+       __result; }))
+#endif
+
 #define MAX_CONTROL_TRANSFER 4096
 #define HEADER_SIZE (sizeof(struct mbim_message_header) + \
 					sizeof(struct mbim_fragment_header))
-- 
2.20.1

